﻿#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the Xcoordination Application Space
 * ("XcoAppSpace") http://www.xcoordination.com
 *
 * Copyright (C) 2009 Xcoordination http://www.xcoordination.com
 *
 * XcoAppSpace is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General
 * Public License as published by the Free Software Foundation.
 *
 * XcoAppSpace is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 * or write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * ---------------------------------------------------------------- */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;

namespace XcoAppSpaces.Contracts.PortWiring
{
	/// <summary>
	/// Infomation about a Port or PortSet concerning serialization.
	/// </summary>
	//[Serializable]
	public class XcoPortSerializationInfo
	{
		/// <summary>
		/// The remote address of the port.
		/// </summary>
		public string RemoteAddress { get; set; }

		/// <summary>
		/// The id of the port.
		/// </summary>
		public Guid RemotePortGuid { get; set; }

		/// <summary>
		/// Creates a new XcoPortSerializationInfo.
		/// </summary>
		public XcoPortSerializationInfo()
		{
		}

		/// <summary>
		/// Creates a new XcoPortSerializationInfo.
		/// </summary>
		/// <param name="remoteAddress">The remote address of the port.</param>
		/// <param name="remotePortGuid">The id of the port.</param>
		public XcoPortSerializationInfo(string remoteAddress, Guid remotePortGuid)
		{
			this.RemoteAddress = remoteAddress;
			this.RemotePortGuid = remotePortGuid;
		}

		/// <summary>
		/// True if the XcoPortSerializationInfo contains remote information (remote address and port id).
		/// </summary>
		public bool IsRemote
		{
			get { return RemoteAddress != null; }
		}

		/// <summary>
		/// Adds remote information to the given XcoPortSerializationInfo.
		/// </summary>
		/// <param name="remoteAddress">The remote address of the port.</param>
		/// <param name="remotePortGuid">The id of the port.</param>
		public void MakeRemote(string remoteAddress, Guid remotePortGuid)
		{
			this.RemoteAddress = remoteAddress;
			this.RemotePortGuid = remotePortGuid;
		}
	}
}
